const domain = "https://api.aslegou.top/api/";
const domainBase = "https://api.aslegou.top/";

function http({ url, method = "GET", data = {}, header = {} }) {
  //显示loading框
  wx.showLoading({
    title: "正在请求",
  });
  return new Promise((resolve, reject) => {
    wx.request({
      url: domain + url,
      header,
      method,
      data,
      success: (res) => {
        wx.hideLoading(); //隐藏loading框
        resolve(res);
      },
      fail: (err) => {
        wx.hideLoading(); //隐藏loading框
        reject(err);
      },
    });
  });
}

export { http, domain, domainBase };
